<template>
    <div style="margin: 10px 0;" @keyup.enter="searchFn()">
        <div>
            <span>
            车行名称：
            <Input v-model="data.dealer_name" placeholder="请输入车行名称" style="width: 100px"></Input>
            </span>
            <span>
            业务员：
            <Select v-model="data.staffId" clearable style="width:100px">
                <Option v-for="item in stafList" :value="item.staffId" :key="item.staffName">{{ item.staffName }}</Option>
            </Select>
            </span>
            <span>
            所属市场：
            <Select v-model="data.bazaar_id" clearable style="width:100px">
                <Option v-for="item in cityList" :value="item.bazaar_id" :key="item.bazaar_id">{{ item.bazzar_title }}</Option>
            </Select>
            </span>
            <span>
            登录账号：
            <Input v-model="data.dealer_tel" placeholder="请输入登录账号" style="width: 100px"></Input>
            </span>
            <span>
            车商等级：
            <Select v-model="data.dealer_level_id" clearable style="width:100px">
                <Option v-for="item in levelList" :value="item.id" :key="item.grade_name">{{ item.grade_name }}</Option>
            </Select>
            </span>
            <span>
            气球：
            <Select v-model="data.finance" clearable style="width:100px">
                <Option value="1" >已加入</Option>
                <Option value="2" >未加入</Option>
            </Select>
            </span>
            <span>
            注册日期：
            <DatePicker @on-change="setTime" type="daterange" placement="bottom-end" placeholder="选择日期"
                        style="width: 200px" ></DatePicker>
            </span>
            <span><input type="checkbox" name="outDealer" v-model="data.outDealer"/>游离商家 </span>
            <Button type="primary" icon="ios-search" style="width: 100px" @click="searchFn">搜索</Button>
            <Button type="primary" style="width: 100px;margin-left: 20px;" @click="batchFn">批量修改费率</Button>
        </div>
    </div>
</template>
<script>
    import API from '../../config/api'
    import qs from 'qs'
    export default {
        props: ['searchData'],
        data() {
            return {
                data: this.searchData,
                cityList: [],
                stafList:[],
                levelList: []
            }
        },
        methods: {
            setTime(time) {
                this.data.dealer_addtime_s = time[0];
                this.data.dealer_addtime_b = time[1] ? time[1] : '';
            },
            searchFn() {
                this.$emit('getAllInfo')
            },
            batchFn(){
            	this.$emit('batchFn')
            },
            getsaltList() {
                this.axios.get('/zscar-api/sales/staff/query/all' ).then(response => {
                    if (response.data.code === 1) {
                        const res = response.data.data;
                        this.stafList = res.list;
                        this.total = res.total;
                    } else {
                        this.$Message.error(response.data.msg);
                    }
                }, response => {
                    console.log(response)
                })
            },
            getBazaar() {
                this.axios.get(API.GET_BAZAAR_LIST).then(response => {
                    if (response.data.code === 1) {
                        this.cityList = response.data.data;
                    } else {
                        this.$Message.error(response.data.msg);
                    }
                }, response => {
                })
            },
            queryGrade(){
                let vm = this ;
                //查询所有数据
                let  params = qs.stringify( {pageSize: 30,
                    pageNum: 1,
                    status:'1'
                });
                this.axios.get( process.env.API_CAR+"/dealer_grade/queryAll?"+ params).then(response=>{
                    if (response.data.code === '1') {
                        let res = response.data.data;
                        let list =  res.list;
                        vm.levelList = list;
                    } else {
                        vm.$Message.error(response.data.info);
                    }
                }, error=>{

                });
            },
        },
        created(){
            this.getBazaar();
            this.getsaltList();
            this.queryGrade();
        }
    }
</script>
<style scoped>
    span {
        margin-bottom: 10px;
        display: inline-block;
        margin-right: 10px;
    }

</style>
